//
//  Rectangle.m
//  Test1
//
//  Created by Seabook Chen on 19/10/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Rectangle.h"
#import "XYPoint.h"

@implementation Rectangle

@synthesize height, width;
@synthesize origin;

-(void) setHeight: (int) _height andWidth: (int) _width {
	height = _height;
	width = _width;
}
-(void) setOrigin: (XYPoint *) _origin {
	if(origin){
		[origin release];
	}
	
	origin = [[XYPoint alloc] init];
	[origin setX:_origin.x andY:_origin.y];
}

-(int) area {
	return height * width;
}

-(int) perimeter {
	return 2 * (height + width);
}

-(void) dealloc {
	if(origin){
		[origin release];
	}
	
	[super dealloc];
}

@end
